Ext.define('appmod.view.role.authorization.Menu', {
    extend: 'Ext.tree.Panel',
    alias: 'widget.menuauthorizationpanel',
	requires:[
		'Ext.ux.tree.TreeEditing'
	],
	rootVisible:false,	
    initComponent: function() {
		
        var me = this;
        Ext.applyIf(me, {
			columns:[{
            	xtype: 'treecolumn', //this is so we know which column will show the tree
            	text: '菜单名称',
            	flex: 2,
            	sortable: true,
            	dataIndex: 'text'
        	}, {
				text :'菜单编码',
				width:200,
				dataIndex:'code'
			} , {
				xtype : 'numbercolumn',
				text : '层次',
				dataIndex:'menuLevel',
				flex: 1,
				format:'0'
			} , {
            	header: '允许访问',
            	dataIndex: 'acl',
            	width: 60,
            	editor: {
                	xtype: 'combobox',
                	typeAhead: true,
                	triggerAction: 'all',
                	selectOnTab: true,
					editable :false,
                	store: Ext.create('Ext.data.ArrayStore', {
					fields:['label' , 'value'],
					data:[
						['默认',''],
						['允许','access'],
						['禁止','deny']
					]
					}),
					displayField:'label',
					valueField: 'value', 
               		lazyRender: true,
               		listClass: 'x-combo-list-small'
           		},
				renderer:function(value) {
					if (value == 'access') {
						return '允许';
					} else if (value == 'deny') {
						return '禁止';
					} else {
						return '默认';
					}						
				}			
			}],
			selType: 'cellmodel',
			plugins:[
				Ext.create('Ext.ux.tree.TreeEditing',{
					clicksToEdit:1
				})
			],
			dockedItems: [
			{
				xtype: 'toolbar',
				dock: 'top',
				items: [
				{
					xtype: 'button',
				    text: '保存菜单授权',
					action:'auth'
				}
				]
			}]			
			
        });

        me.callParent(arguments);
    }
});